package com.dog.basics.common.util;

import net.dongliu.apk.parser.ApkFile;
import net.dongliu.apk.parser.bean.ApkMeta;

import java.io.IOException;

/**
 * @program: singingtogether
 * @description: APK包信息
 * @author: Guo
 * @create: 2019-12-18 16:43
 **/
public class ApkVersionInfo {

    /**
     * 获取版本等信息
     *
     * @param filePath
     * @return
     */
    public ApkMeta apkVersionInfo(String filePath) {
        try (ApkFile apkFile = new ApkFile(filePath)) {
            ApkMeta apkMeta = apkFile.getApkMeta();
            //resMap.put("pkgname", apkMeta.getPackageName());
            //resMap.put("versioncode", apkMeta.getVersionCode());
            //resMap.put("versionname", apkMeta.getVersionName());
            //for (UseFeature feature : apkMeta.getUsesFeatures()) {
            //System.out.println(feature.getName());
            //}
            return apkMeta;
        } catch (IOException e) {
            return null;
        }
    }
}
